package routers

import (
	"github.com/astaxie/beego"
	"lazyops_go/rbacControllers"
)

func init() {

	//登陆过滤找到路由之前
	beego.InsertFilter("/*", beego.BeforeRouter, LoginFilter)
	//找到路由后执行controller 之前
	beego.InsertFilter("/rbac/*", beego.BeforeExec, PermsFilter)

	//首页
	beego.Router("/", &rbacControllers.IndexController{}, "get:Login")
	beego.Router("/login/", &rbacControllers.IndexController{}, "post:DoLogin")
	beego.Router("/logout/", &rbacControllers.IndexController{}, "get:Logout")
	beego.Router("/index/", &rbacControllers.IndexController{})

	//角色增删改查
	beego.Router("/rbac/role/", &rbacControllers.RoleController{}, "get:IndexRole")
	beego.Router("/rbac/role/:page/", &rbacControllers.RoleController{}, "get:IndexRole")
	beego.Router("/rbac/addrole/", &rbacControllers.RoleController{}, "post:CreateRole")
	beego.Router("/rbac/idrole/", &rbacControllers.RoleController{}, "post:GetRoleById")
	beego.Router("/rbac/editrole/", &rbacControllers.RoleController{}, "put:EditRole")
	beego.Router("/rbac/delrole/", &rbacControllers.RoleController{}, "post:DelRole")
	beego.Router("/rbac/searchrole/:key/", &rbacControllers.RoleController{}, "get:SearchRole")
	beego.Router("/rbac/getperms/", &rbacControllers.RoleController{}, "post:GetPerms")
	beego.Router("/rbac/editroleperms/", &rbacControllers.RoleController{}, "post:EditRolePerms")
	beego.Router("/rbac/getpfm/", &rbacControllers.RoleController{}, "post:GetPfm")
	beego.Router("/rbac/editrolepfm/", &rbacControllers.RoleController{}, "post:EditRolePfm")

	//用户增删改查
	beego.Router("/rbac/user/", &rbacControllers.UserController{}, "get:IndexUser")
	beego.Router("/rbac/adduser/", &rbacControllers.UserController{}, "post:CreateUser")
	beego.Router("/rbac/iduser/", &rbacControllers.UserController{}, "post:GetUserById")
	beego.Router("/rbac/edituser/", &rbacControllers.UserController{}, "put:EditUser")
	beego.Router("/rbac/deluser/", &rbacControllers.UserController{}, "post:DelUser")
	beego.Router("/rbac/changepwd/", &rbacControllers.UserController{}, "post:ChangeUserPwd")
	beego.Router("/rbac/searchuser/:key", &rbacControllers.UserController{}, "get:SearchUser")

	//菜单管理
	beego.Router("/rbac/menu/", &rbacControllers.MenuController{}, "get:IndexMenu")
	beego.Router("/rbac/addmenu/", &rbacControllers.MenuController{}, "post:CreateMenu")
	beego.Router("/rbac/idmenu/", &rbacControllers.MenuController{}, "post:GetMenuById")
	beego.Router("/rbac/editmenu/", &rbacControllers.MenuController{}, "put:EditMenu")
	beego.Router("/rbac/delmenu/", &rbacControllers.MenuController{}, "post:DelMenu")
	beego.Router("/rbac/searchmenu/:key", &rbacControllers.MenuController{}, "get:SearchMenu")

	//字典增删改查
	beego.Router("/rbac/dict/", &rbacControllers.DictController{}, "get:IndexDict")
	beego.Router("/rbac/dict/:page/", &rbacControllers.DictController{}, "get:IndexDict")
	beego.Router("/rbac/addict/", &rbacControllers.DictController{}, "post:CreateDict")
	beego.Router("/rbac/iddict/", &rbacControllers.DictController{}, "post:GetDictById")
	beego.Router("/rbac/editdict/", &rbacControllers.DictController{}, "put:EditDict")
	beego.Router("/rbac/deldict/", &rbacControllers.DictController{}, "post:DelDict")
	beego.Router("/rbac/searchdict/:key/", &rbacControllers.DictController{}, "get:SearchDict")
}
